home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ABox 1.9.5 / ABox info... / About the ABox... / Programming Info / 2-Modifying source / 2-Modifying source.rsrc / TEXT_231_Making the abox happen.txt < prev    next >
Encoding:
Text File  |  1994-07-13  |  2.5 KB  |  86 lines

  1. Once you've got the ABox all built and ready to go, you need to tell it to draw itself on the screen...
  2.  
  3. OSErr    ABox::Draw(WindowPtr window);
  4.  
  5. You can pass nearly anything in the "window" argument; it is currently unused, and a "NULL" will work very nicely right now.
  6.  
  7. Now that the ABox is up and on the screen, you've got to allow it to receive events. You do this by using the method below in one of two ways
  8.  
  9. Boolean    ABox::Event(EventRecord *event);
  10.  
  11. (1) Send it a NULL for the event; this will prime the ABox, and if you have instructed it to operate as a Modal Dialog, it will block until the Modal Dialog version of the ABox is dismissed by the user. Below is a sample:
  12.  
  13. gABox = new ABox;
  14. if (gABox)
  15. {
  16.   // PrepareABox is from the earlier example on 
  17.   // setting properties
  18.   error = PrepareABox (gABox, 
  19.                        splashTime, 
  20.                        modality, 
  21.                        &homeSpec);
  22.   error = gABox->Draw(NULL);
  23.   error = gABox->Event(NULL);
  24. }
  25.  
  26. OR
  27.  
  28. (2) Incorporate the ABox's Event method into your application's main event loop. This is generally the preferred method, as it allows the ABox to operate in any fashion--even as a splash screen. Below is a sample:
  29.  
  30. do 
  31. {
  32.    // Get an event...
  33.    WaitNextEvent(everyEvent, 
  34.                  &eRecord,
  35.                  mySleep, 
  36.                  nil);
  37.    
  38.    // if we have an ABox up and running,
  39.    // allow it first shot at the event
  40.    if (gABox)
  41.    {
  42.       Boolean    aboxFinished = false;
  43.             
  44.          aboxHandled = gABox->Event(&eRecord);
  45.  
  46.       // is the ABox now finished?
  47.                error = gABox->GetProperty (kABoxIsFinished, 
  48.                                            &aboxFinished, 
  49.                                            NULL);
  50.                         if (aboxFinished)
  51.                         {
  52.           // yes, the ABox is done and over with
  53.           delete gABox;
  54.           gABox = NULL;
  55.                         } else if (aboxHandled) {
  56.           // did the ABox handle the event? Should
  57.           // we further process it? Yes, if we
  58.           // are here...
  59.                                         continue;
  60.                         } // end if block
  61.             } // end if block
  62.         
  63.    // normal event processing here since either
  64.    // we don't have an ABox, the ABox is finished,
  65.    // or the ABox didn't want the event.
  66.       switch (eRecord.what) 
  67.    {
  68.                //    blah blah blah...
  69.             
  70.          //    general event handling here
  71.                  
  72.    } // end switch block
  73.  
  74. }    while (gQuit != true);
  75.  
  76.  
  77. That's about it... just remember to delete the ABox
  78. via the standard C++ delete mechanism
  79.  
  80. if (gABox)
  81.    delete gABox;
  82.  
  83. This is also shown in the above code fragment
  84. as part of the event loop.
  85.  
  86.